package cn.stylefeng.guns.modular.business.frequency.cmcompanyorder.mapper;

import cn.stylefeng.guns.modular.business.frequency.cmcompany.model.param.CompanyOrderDTO;
import cn.stylefeng.guns.modular.business.frequency.cmcompany.model.result.PkgCompanyOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.stylefeng.guns.modular.business.frequency.cmcompanyorder.entity.CmCompanyOrder;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 通讯录联系人表 Mapper 接口
 *
 * @author yujie
 * @date 2023/05/09 17:17
 */
public interface CmCompanyOrderMapper extends BaseMapper<CmCompanyOrder> {

    Page<PkgCompanyOrder> getCompanyOrderListPage(@Param("companyId") String companyId,
                                                   @Param("page") Page page, @Param("companyOrderDTO") CompanyOrderDTO companyOrderDTO);
    @Select("select id,order_id as orderId from cm_company_order where order_id = #{orderId} and `type` = #{type}")
    CmCompanyOrder getByOrderIdAndType(@Param("orderId") Long orderId, @Param("type") int type);

    @Update("update cm_company_order set company_id = #{companyId} where linkman_id = #{linkmanId}")
    void updateCompanyIdByLinkmanId(@Param("companyId") Long companyId, @Param("linkmanId") Long linkmanId);

    @Update("update cm_company_order set driver_name = #{driverName}, driver_phone = #{driverPhone} where order_id = #{orderId} and type = #{type}")
    void updateDriverInfo(@Param("orderId") String orderId, @Param("type") int type,
                          @Param("driverName") String driverName, @Param("driverPhone") String driverPhone);
}